#!/user/bin/env python3
# -*- coding: utf-8 -*-

from PIL import Image,ImageFilter

image1 = Image.open('../files/split.jpg')

# 1.条件系统滤镜
# 生成一个浮雕效果的新图片
image2 = image1.filter(ImageFilter.EMBOSS)
# image2.show()
# image2.save('../files/split_emboss.jpg')

# 生成铅笔画效果
image3 = image1.filter(ImageFilter.CONTOUR)
# image3.show()

# 模糊效果
image4 = image1.filter(ImageFilter.BLUR)
# image4.show()

# 边缘增强
image5 = image1.filter(ImageFilter.EDGE_ENHANCE)
# image5.show()

# 自定义滤镜
class MY_ENHANCE(ImageFilter.BuiltinFilter):
    name = "Edge-enhance"
    # (3,3)表示 3*3的矩阵，具体调整后面的数字观察
    filterargs = (3, 3), 2, 0, (
        -1, -1, -1,
        -1, 9, -1,
        -1, -1, -1,
    )
image6 = image1.filter(MY_ENHANCE)
image6.show()